from django.db import models
from intr.models.models import Society
import time

class Event(models.Model):
	name = models.CharField(max_length=200)
	slug = models.SlugField()
	location = models.CharField(max_length=200)
	lat = models.DecimalField(blank=True,max_digits=10,decimal_places=5)
	lon = models.DecimalField(blank=True,max_digits=10,decimal_places=5)
	start = models.DateTimeField()
	end = models.DateTimeField()
	description = models.TextField()
	society = models.ForeignKey(Society)

	def __unicode__(self):
		return self.name
	
	def start_timestamp(self):
		return int(time.mktime(self.start.timetuple())*1000)
	
	def end_timestamp(self):
		return int(time.mktime(self.end.timetuple())*1000)

	permissions = (
			("create_event", "Can create a new society"),
			("edit_event", "Can edit society details"),
			("delete_event", "Can delete a society")
		)
